//
//  ViewController.m
//  u76ho
//
//  Created by m-air-01 on 15/12/24.
//  Copyright © 2015年 LV. All rights reserved.
//

#import "ViewController.h"

#define TabColor  [UIColor whiteColor]

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.selectedImageTintColor = [UIColor colorWithRed:0.43 green:0.78 blue:0.27 alpha:1.00];
    //1首页
    HomePageVC * HpVCT = [[HomePageVC alloc]init];
    UINavigationController * HpVCTYNC = [[UINavigationController alloc]initWithRootViewController:HpVCT];
    [HpVCTYNC.navigationBar setBarTintColor:TabColor];
    //2在益企
    AtYiQiVC * AyqVCT = [[AtYiQiVC alloc]init];
    UINavigationController * AyqVCTNC = [[UINavigationController alloc]initWithRootViewController:AyqVCT];
    [AyqVCTNC.navigationBar setBarTintColor:TabColor];
    //3占位视图控制器
    UIViewController * dVCT = [[UIViewController alloc]init];
//    UINavigationController * dVCTNC = [[UINavigationController alloc]initWithRootViewController:dVCT];
//    [dVCTNC.navigationBar setBarTintColor:[UIColor whiteColor]];
    //4发现
    FindVC * FVCT = [[FindVC alloc]init];
    UINavigationController * FVCTNC = [[UINavigationController alloc]initWithRootViewController:FVCT];
    [FVCTNC.navigationBar setBarTintColor:TabColor];
    //5我
    MineVC * MVCT = [[MineVC alloc]init];
    UINavigationController * MVCTNC = [[UINavigationController alloc]initWithRootViewController:MVCT];
    [MVCTNC.navigationBar setBarTintColor:TabColor];
    self.viewControllers = @[HpVCTYNC,AyqVCTNC,dVCT,FVCTNC,MVCTNC];
    
    NSArray * array = @[@"首页",@"在益企",@"发布",@"发现",@"我"];
    NSArray * SelegateimageArray = @[@"首页－选中",@"益企－选中",@"发布图标",@"发现-选中",@"我－选中"];
    
    NSArray * imageArray =  @[@"首页",@"益企",@"发布图标",@"发现",@"我－图标"];
    
    for (int i =0 ; i<5; i++) {
        
        UITabBarItem * item = self.tabBar.items[i];
        
        item.title = array[i];
        
        item.tag = i;
        
        item.selectedImage =[ [UIImage imageNamed:SelegateimageArray[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
        
        item.image = [[UIImage imageNamed:imageArray[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        
        
        if (i == 2) {
            
            //item.imageInsets = UIEdgeInsetsMake(-5, -2, 0, -2);
            
            item.titlePositionAdjustment =UIOffsetMake(0, -5) ;
            
            
        }
        
        
    }
    
//    self.selectedIndex = 1;
    

    
    


}

-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
    
    

    if (item.tag == 2) {
        
         self.tabBar.hidden = YES;
        
        DistubuteVC * DisTu = [[DistubuteVC alloc]init];
        
        
      //  DisTu.modalTransitionStyle = UIModalTransitionStylePartialCurl;
       // DisTu.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        //HomePageVC * home = [[HomePageVC alloc]init];
        
        [self presentViewController:DisTu animated:YES completion:^{
            self.selectedIndex = 0;
            
           
        }];
        
    }


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
